package com.controller;

import com.entry.PageBean;
import com.entry.Product;
import com.server.ShoppingProductService;
import com.server.impl.ProductServiceImpl;
import com.server.impl.ShoppingProductServiceImpl;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
public class ProductController {
    @Resource
    ProductServiceImpl productService;
    @Resource
    ShoppingProductServiceImpl shoppingProductService;

    @RequestMapping( value = "/product/findproductListSelect",method = RequestMethod.POST)
    public String getproducandproductimageList(@Param("SelectName")String SelectName, @RequestParam(value = "currentPage",defaultValue = "1",required = false)int currentPage, Model model, HttpSession session){
        //PageBean<Product> pageBean=productService.findProductByPage(currentPage);
        List<Product> productList=productService.SelectNameCount(SelectName);
        //回显分页数据

        PageBean<Product> pageBean=new PageBean<>();
        pageBean.setLists(productList);
        model.addAttribute("pageBean",pageBean);
        session.setAttribute("pageBean",pageBean);
        return "listselect";
    }

}
